package com.yangff.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yangff.anno.LogExecuteTime;
import com.yangff.entity.user.entity.dto.UserDTO;
import com.yangff.entity.user.entity.vo.UserVo;
import com.yangff.entity.vo.ResultVo;
import com.yangff.service.IUsermanagementService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 存储管理员对用户的管理操作记录 前端控制器
 * </p>
 *
 * @author yangff
 * @since 2025-01-15
 */
@LogExecuteTime
@RestController
@RequiredArgsConstructor
@RequestMapping("/usermanagement")
@Slf4j
public class UsermanagementController {
    private final IUsermanagementService usermanagementService;

    @GetMapping
    public Page<UserVo> selectUser(@PageableDefault Pageable pageable) {

        return usermanagementService.selectUser(pageable);
    }

    //修改用户状态为，传入账号和设定状态即可
    @PutMapping("/reset-status")
    public UserVo updateUserStatusByAccount(@RequestBody UserDTO userDTO)
    {
        return usermanagementService.updateUserStatusByAccount(userDTO);
    }

    //修改用户信息，慎用
    @PutMapping
    public UserVo updateUserByAccount(@RequestBody UserDTO userDTO)
    {
       return usermanagementService.updateUserByAccount(userDTO);
    }

    @DeleteMapping("/{account}")
    public ResultVo deleteUserByAccount(@PathVariable String account)
    {
        return usermanagementService.deleteUserByAccount(account);
    }



}
